package com.leyou.item.controller;

import com.leyou.item.dto.CategoryDTO;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：qcq
 * @date ：Created in 2020/12/4 13:33
 * @description：
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/{id}")
    public ResponseEntity<CategoryDTO> queryCategoryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(categoryService.queryCategoryById(id));
    }

    @GetMapping("/list")
    public ResponseEntity<List<CategoryDTO>> queryCategoryByIdList(@RequestParam("ids") List<Long> ids) {
        return ResponseEntity.ok(categoryService.queryCategoryByIdList(ids));
    }

    @GetMapping("/of/brand")
    public ResponseEntity<List<CategoryDTO>> queryCategoryByBrandId(@RequestParam("id") Long id) {
        return ResponseEntity.ok(categoryService.queryCategoryByBrandId(id));
    }

    @GetMapping("/of/parent")
    public ResponseEntity<List<CategoryDTO>> queryCategoryByParentId(@RequestParam("pid") Long id) {
        return ResponseEntity.ok(categoryService.queryCategoryByParentId(id));
    }
}

